import java.io.*;  
import java.util.*;  
  
public class E {  
    public static void main(String args[]) {  
        File file = new File("a.txt");  
        Scanner sc = null;  
        PrintWriter pw = null;   
        double sum = 0;  
        int count = 0;  
        try {  
            sc = new Scanner(file);  
            sc.useDelimiter("[^0123456789.]+");  
            while (sc.hasNext()) {  
                try {  
                    double price = sc.nextDouble();  
                    count++;  
                    sum = sum + price;  
                    
                } catch (InputMismatchException exp) {  
                    sc.next();  
                }  
            }  
            double average = (count > 0) ? sum / count : 0;  
            System.out.println("平均价格：" + average);  
  
              
            pw = new PrintWriter(new FileWriter(file, true));  
            pw.println("平均价格：" + average);  
            pw.flush(); // 确保数据被写入文件  
  
        } catch (Exception exp) {  
            System.out.println(exp);  
        } finally {  
            // 关闭Scanner和PrintWriter以释放资源  
            if (sc != null) {  
                sc.close();  
            }  
            if (pw != null) {  
                pw.close();  
            }  
        }  
    }  
}